package cn.t.web.sku;

import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.dto.api.CustomerItemDTO;
import cn.t.facade.sku.SkuFacade;
import cn.t.request.CreateSkuReq;
import cn.t.request.SkuReq;
import cn.t.vo.sku.SkuVo;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品表(Sku)服务入口
 *
 * @author s
 * @since 2024-06-11
 */
@Slf4j
@RestController
@RequestMapping("sku")
// "商品服务")
@AllArgsConstructor
public class SkuController {

    @Autowired
    protected SkuFacade facade;

    /**
     * 商品列表分页查询接口
     */
    @PostMapping(value = "/page")
    public PageInfoDTO<SkuVo> findSkuByPage(@RequestBody PageQueryDTO<SkuReq> req) {return facade.findSkuByPage(req);}

    /**
     * 新增商品
     */
    @PostMapping("/add")
    public Boolean add(@Validated @RequestBody CreateSkuReq req) {return facade.add(req);}

    /**
     * 商品详情接口
     */
    @GetMapping(value = "/detail/{skuCode}")
    public SkuVo detail(@PathVariable String skuCode) {return facade.detail(skuCode);}

    /**
     * 商品启用禁用
     */
    @PostMapping("/status/update")
    public Boolean updateStatus(@RequestBody CreateSkuReq req) {
        return facade.updateStatus(req.getSkuCode(), req.getStatus());
   }

    /**
     * 编辑商品
     */
    @PostMapping("/update")
    public Boolean update(@Validated @RequestBody CreateSkuReq req) {return facade.update(req);}




}

